
<template>
  <div>
    <div id="slider" class="mui-slider">
      <div
        id="sliderSegmentedControl"
        class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted"
      >
        <div class="mui-scroll">
          <a
            :class="['mui-control-item',index==0?'mui-active':'']"
            href="#item2mobile"
            data-wid="tab-top-subpage-2.html"
            @click="getPhotos(item.id)"
            v-for="(item,index) in category"
            :key="item.id"
          >{{item.title}}</a>
        </div>
      </div>
    </div>

    <ul class="photo-list">
      <router-link v-for="item in photos" :key="item.id" :to="'/home/photoinfo/'+item.id" tag="li">
        <img v-lazy="item.url">
        <div class="info">
          <div class="info-title">{{item.title}}</div>
          <div class="info-content">{{item.content}}</div>
        </div>
      </router-link>
    </ul>
  </div>
</template>

<script>
import mui from "../../lib/mui/js/mui.js";

export default {
  data() {
    return {
      category: [],
      photos: []
    };
  },
  methods: {
    getCategory() {
      this.$http.get("/src/data/category.json").then(res => {
        this.category = res.body;
      });
    },
    getPhotos(id) {
      this.$http.get("/src/data/photo" + (id % 2) + ".json").then(res => {
        this.photos = res.body;
        console.log(this.photos);
      });
    }
  },
  mounted() {
    mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });

    this.getCategory();
    this.getPhotos(0);
  }
};
</script>

<style lang="scss" scoped>
* {
  touch-action: pan-y;
}

.photo-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  li {
     position: relative;
    margin-bottom: 50px;
    background-color: #ccc;
    text-align: center;
    img {
      width: 100%;
      vertical-align: middle;
      box-shadow: 0 0 6px #999;
    }
    img[lazy="loading"] {
      width: 40px;
      height: 300px;
      margin: auto;
    }
  }
}
.info {
  bottom: 0px;
  background-color: rgba(0,0,0,0.4);
  position: absolute;
  color: white;
  text-align: left;
  max-height: 84px;
  .info-title {
   
    font-size: 14px;
  }
  .info-content {
    font-size: 12px;
    
    
  }
}
</style>
